﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace NDF.XnaLibrary.Models
{
	public class GameObject : GameModel, IIndependentlyMoving
	{
		private Vector3 mPosition;
		private Quaternion mRotation;
		private Matrix mWorldMatrix;

		public GameObject(Model model, Effect effect)
			: base(model, effect)
		{}

		public GameObject(Model model, Effect effect, Vector3 position, Quaternion rotation, string name)
			: base(model, effect, name)
		{
			this.mPosition = position;
			this.mRotation = rotation;
			this.mWorldMatrix = Matrix.CreateScale(this.mScale) *
				Matrix.CreateFromQuaternion(this.mRotation) *
				Matrix.CreateTranslation(this.mPosition);
		}

		public Vector3 Position
		{
			get { return mPosition; }
			set 
			{
				mPosition = Utilities.GetPositionInMap(value);
			}
		}

		public Quaternion Rotation
		{
			get { return mRotation; }
			set { mRotation = value; }
		}

		public override void SaveEffectChanges()
		{
			base.SaveEffectChanges(Effect);
		}
	}
}
